#include <typedef.h>
#include <utils.h>
#include <elf.h>
#include <multiboot.h>
#include <mem.h>

void elf_init(struct multiboot* mb)
{
  elf_sh *sh;
  char *strtab;
  u32 i;
  symtab syms;
  
  kprintf("Elf(%x, %x, %x, %x):\n", mb->num, mb->size, mb->addr, mb->shndx);
  sh = (elf_sh*) mb->addr;
  strtab = (char*) sh[mb->shndx].sh_addr;
  for(i = 0; i < mb->num; i++)
  {
    kprintf("  Addr: %x Size: %x Type: %x %s\n", sh[i].sh_addr, sh[i].sh_size, sh[i].sh_type, &strtab[sh[i].sh_name]);
    mem_used(sh[i].sh_addr, sh[i].sh_size, ELF_TYPE);
    if(sh[i].sh_type == SHT_SYMTAB)
    {
      syms.syms = sh[i].sh_addr;
      syms.numsyms = sh[i].sh_size/sizeof(elf_sym);
      kprintf("    %x symbols\n", syms.numsyms);
    }
  }  
} 

u32 elf_lookup_symbol(symtab syms, char *name, u32 *symbol)
{
  return;
}

u32 elf_check(elf_hdr *hdr)
{
  return (u32)hdr;
}
